﻿@model ConferenceStatisticsModel
@{
	ViewBag.Title = Resources.ConferenceStatistics + ConstValues.strDash + ViewBag.ConferenceName;
}
<div class="easyui-tabs" id="tt">
	<div title="@Resources.StatisticsContribute">
		<div id="menuBar" style="height:35px;">
			<div style="float: left; padding: 5px 5px; font-weight: bold; text-align: left;">
				@Resources.TopicName：<select id="ddlTopic" class="easyui-combobox" style="height:27px; width:200px;"></select>&nbsp;&nbsp;
				@Resources.JournalName：<select id="ddlJournal" class="easyui-combobox" style="height:27px; width:200px;"></select>&nbsp;&nbsp;
				<a href="javascript:void(0);" class="easyui-linkbutton" iconcls="icon-search" onclick="searchData(1);">@Resources.Search</a>
			</div>
			<div class="clear"></div>
		</div>
		<div id="dataGrid1"></div>
	</div>
	<div title="@Resources.StatisticsAttendence">
		<div id="menuBar" style="height:35px;">
			<div style="float: left; padding: 5px 5px; font-weight: bold; text-align: left;">
				@Resources.SearchCondition：<select id="ddlStatisticsGroupType" class="easyui-combobox" style="height:27px; width:200px;" data-options="editable:false, panelHeight:'auto'">
					<option value="">@Resources.All</option>
					<option value="@ConstValues.StatisticsGroupType.Country">@Resources.Country</option>
					<option value="@ConstValues.StatisticsGroupType.Title">@Resources.Title</option>
					<option value="@ConstValues.StatisticsGroupType.Job">@Resources.Job</option>
					<option value="@ConstValues.StatisticsGroupType.Affiliation">@Resources.Affiliation</option>
					<option value="@ConstValues.StatisticsGroupType.PayType">@Resources.PaymentType</option>
					<option value="@ConstValues.StatisticsGroupType.PaidStatus">@Resources.PayStatus</option>
					<option value="@ConstValues.StatisticsGroupType.ArriveStatus">@Resources.HasArrived</option>
				</select>&nbsp;&nbsp;
				<a href="javascript:void(0);" class="easyui-linkbutton" iconcls="icon-search" onclick="searchData(2);">@Resources.Search</a>
			</div>
			<div class="clear"></div>
		</div>
		<div id="dataGrid2"></div>
	</div>
	<div title="@Resources.StatisticsHotel">
		<div id="menuBar" style="height:35px;">
			<div style="float: left; padding: 5px 5px; font-weight: bold; text-align: left;">
				@Resources.Hotel：<select id="ddlHotel" class="easyui-combobox" style="height:27px; width:200px;"></select>&nbsp;&nbsp;
				<a href="javascript:void(0);" class="easyui-linkbutton" iconcls="icon-search" onclick="searchData(3);">@Resources.Search</a>
			</div>
			<div class="clear"></div>
		</div>
		<div id="dataGrid3"></div>
	</div>
	<div title="@Resources.StatisticsInvoice">
		<div id="menuBar" style="height:35px;">
			<div style="float: left; padding: 5px 5px; font-weight: bold; text-align: left;">
				@Resources.InvoiceTitle：<input id="txtInvoiceTitle" class="easyui-textbox" style="height:27px; width:200px;" />&nbsp;&nbsp;
				@Resources.TaxNum：<input id="txtTaxNum" class="easyui-textbox" style="height:27px; width:200px;" />&nbsp;&nbsp;
				<a href="javascript:void(0);" class="easyui-linkbutton" iconcls="icon-search" onclick="searchData(4);">@Resources.Search</a>&nbsp;&nbsp;
				<a href="javascript:void(0);" class="easyui-linkbutton" iconcls="icon-export" onclick="exportInvoiceData();" plain="true">@Resources.Export</a>
			</div>
			<div class="clear"></div>
		</div>
		<div id="dataGrid4"></div>
	</div>
	<div title="@Resources.StatisticsNotInvoice">
		<div id="menuBar" style="height:35px;">
			<div style="float: left; padding: 5px 5px; font-weight: bold; text-align: left;">
				@Resources.InvoiceTitle：<input id="txtNotInvoiceTitle" class="easyui-textbox" style="height:27px; width:200px" />&nbsp;&nbsp;
				@Resources.TaxNum：<input id="txtNotTaxNum" class="easyui-textbox" style="height:27px; width:200px" />&nbsp;&nbsp;
				<a href="javascript:void(0);" class="easyui-linkbutton" iconcls="icon-search" onclick="searchData(5);">@Resources.Search</a>&nbsp;&nbsp;
				<a href="javascript:void(0);" class="easyui-linkbutton" iconcls="icon-export" onclick="exportNotInvoiceData();" plain="true">@Resources.Export</a>
			</div>
			<div class="clear"></div>
		</div>
		<div id="dataGrid5"></div>
	</div>
</div>

<form id="invoiceExport" method="post" target="iframeDownload" action="@Url.Action(nameof(ConferenceStatisticsController.ExportInvoice))">
	@Html.AntiForgeryToken()
	<input type="hidden" id="hidInvoiceTitle" name="hidInvoiceTitle" />
	<input type="hidden" id="hidTaxNum" name="hidTaxNum" />
	<input type="hidden" id="hidConferenceId" name="hidConferenceId" />
	<input type="hidden" id="hidHasInvoiced" name="HidHasInvoiced" />
</form>

@section Scripts {
<script>
	common.setCurrentMenu("ConferenceStatistics");

	$(function () {
		$("#tt").tabs({
			width: $(window).width() - 265,
		});

		var orgCount = 0;
		$("#ddlTopic").combobox({
			url: "@Url.Action(nameof(UtilityController.GetTopicWithAll),
					nameof(UtilityController).GetControllerName())" + "?conferenceId=" + "@Model.ConferenceId",
			editable: false,
			valueField: "id",
			textField: "name",
			onLoadSuccess: function(data) {
				orgCount = data.length;
				$(this).combobox("setValue", "");
			},
			onShowPanel: function () {
				if (orgCount < 10) {
					$(this).combobox("panel").height("auto");
				} else {
					$(this).combobox("panel").height(200);
				}
			}
		});

		var orgCount_2 = 0;
		$("#ddlJournal").combobox({
			url: "@Url.Action(nameof(UtilityController.GetJournalWithAll),
					nameof(UtilityController).GetControllerName())" + "?conferenceId=" + "@Model.ConferenceId",
			editable: false,
			valueField: "id",
			textField: "name",
			onLoadSuccess: function(data) {
				orgCount_2 = data.length;
				$(this).combobox("setValue", "");
			},
			onShowPanel: function () {
				if (orgCount_2 < 10) {
					$(this).combobox("panel").height("auto");
				} else {
					$(this).combobox("panel").height(200);
				}
			}
		});

		var orgCount_3 = 0;
		$("#ddlHotel").combobox({
			url: "@Url.Action(nameof(UtilityController.GetHotelWithAll),
					nameof(UtilityController).GetControllerName())" + "?conferenceId=" + "@Model.ConferenceId",
			editable: false,
			valueField: "id",
			textField: "name",
			onLoadSuccess: function(data) {
				orgCount_3 = data.length;
				$(this).combobox("setValue", "");
			},
			onShowPanel: function () {
				if (orgCount_3 < 10) {
					$(this).combobox("panel").height("auto");
				} else {
					$(this).combobox("panel").height(200);
				}
			},
		});

		$("#ddlStatisticsGroupType").combobox("setValue", "");

		$("#ddlTopic").textbox("textbox").bind("keydown", function (e) {
			if (e.keyCode == 13) {
				searchData(1);
			}
		});
		$("#ddlJournal").textbox("textbox").bind("keydown", function (e) {
			if (e.keyCode == 13) {
				searchData(2);
			}
		});
		$("#ddlHotel").textbox("textbox").bind("keydown", function (e) {
			if (e.keyCode == 13) {
				searchData(3);
			}
		});
		$("#txtInvoiceTitle").textbox("textbox").bind("keydown", function (e) {
			if (e.keyCode == 13) {
				searchData(4);
			}
		});
		$("#txtTaxNum").textbox("textbox").bind("keydown", function (e) {
			if (e.keyCode == 13) {
				searchData(4);
			}
		});
		$("#txtNotInvoiceTitle").textbox("textbox").bind("keydown", function (e) {
			if (e.keyCode == 13) {
				searchData(5);
			}
		});
		$("#txtNotTaxNum").textbox("textbox").bind("keydown", function (e) {
			if (e.keyCode == 13) {
				searchData(5);
			}
		});

		$("#dataGrid1").datagrid({
			url: "@Url.Action(nameof(ConferenceStatisticsController.GetContribute),
					nameof(ConferenceStatisticsController).GetControllerName(), new { ConferenceId = Model.ConferenceId })",
			method: "get",
			fitColumns: true,
			width: $(window).width() - 285,
			height: $(window).height() - 158 - 35,
			nowrap: false,
			pagination: true,
			pageSize: @ConstValues.DefaultGridRows,
			striped: true,
			toolbar: "#toolBar",
			pageSize: 100,
			pageList: [100, 200, 300, 400, 500],
			columns: [[
				{ field: "topicName", title: "@Resources.TopicName", align: "center", sortable: true, width: 200 },
				{ field: "journalName", title: "@Resources.JournalName", align: "center", sortable: true, width: 200 },
				{ field: "inviteReportCount", title: "@Resources.InviteReportCount", align: "center", sortable: true, width: 100 },
				{ field: "oralReportCount", title: "@Resources.OralReportCount", align: "center", sortable: true, width: 100 } ,
				{ field: "postReportCount", title: "@Resources.PostReportCount", align: "center", sortable: true, width: 100 }
			]],
			onBeforeLoad: function(param) {
				param.random = Math.random();
			}
		});

		$("#dataGrid2").datagrid({
			url: "@Url.Action(nameof(ConferenceStatisticsController.GetAttendence),
					nameof(ConferenceStatisticsController).GetControllerName(), new { ConferenceId = Model.ConferenceId })",
			method: "get",
			fitColumns: true,
			width: $(window).width() - 285,
			height: $(window).height() - 158 - 35,
			nowrap: false,
			pagination: true,
			pageSize: @ConstValues.DefaultGridRows,
			striped: true,
			toolbar: "#toolBar",
			pageSize: 100,
			pageList: [100, 200, 300, 400, 500],
			columns: [[
				{ field: "country", title: "@Resources.Country", align: "center", sortable: true, width: 100 },
				{ field: "title", title: "@Resources.Title", align: "center", sortable: true, width: 100 },
				{ field: "job", title: "@Resources.Job", align: "center", sortable: true, width: 100 },
				{ field: "affiliation", title: "@Resources.Affiliation", align: "center", sortable: true, width: 100 },
				{ field: "paymentName", title: "@Resources.PaymentType", align: "center", sortable: true, width: 50 },
				{
					field: "hasPaid", title: "@Resources.PaidStatus", align: "center", sortable: true, width: 50,
					formatter: function (value, rec) {
						if (value == true) {
							return "@Resources.HasPaid";
						} else if (value == false) {
							return "@Resources.HasNotPaid";
						} else {
							return "";
						}
					}
				},
				{
					field: "hasArrived", title: "@Resources.HasArrived", align: "center", sortable: true, width: 50,
					formatter: function (value, rec) {
						if (value == true) {
							return "@Resources.Yes";
						} else if (value == false) {
							return "@Resources.No";
						} else {
							return "";
						}
					}
				},
				{ field: "count", title: "@Resources.Count", align: "center", sortable: true, width: 100 }
			]],
			onBeforeLoad: function(param) {
				param.random = Math.random();
			}
		});

		$("#dataGrid3").datagrid({
			url: "@Url.Action(nameof(ConferenceStatisticsController.GetHotelRoom),
					nameof(ConferenceStatisticsController).GetControllerName(), new { ConferenceId = Model.ConferenceId })",
			method: "get",
			fitColumns: true,
			width: $(window).width() - 285,
			height: $(window).height() - 158 - 35,
			nowrap: false,
			pagination: true,
			pageSize: @ConstValues.DefaultGridRows,
			striped: true,
			toolbar: "#toolBar",
			pageSize: 100,
			pageList: [100, 200, 300, 400, 500],
			remoteSort: false,
			columns: [[
				{ field: "hotelName", title: "@Resources.HotelName", align: "center", sortable: true, width: 200 },
				{ field: "roomType", title: "@Resources.RoomType", align: "center", sortable: true, width: 200 },
				@for (var index = 0; index < Model.DayList.Count; index ++) {
					<text>
					{ field: "day" + @index.ToString(), title: "@Model.DayList[index]", align: "center", sortable: true, width: 100 },
					</text>
				}
			]],
			onBeforeLoad: function(param) {
				param.days = @Model.Days;
				param.random = Math.random();
			},
		});

		$("#dataGrid4").datagrid({
			url: "@Url.Action(nameof(ConferenceStatisticsController.GetInvoice),
					nameof(ConferenceStatisticsController).GetControllerName(), new { ConferenceId = Model.ConferenceId })",
			method: "get",
			fitColumns: true,
			width: $(window).width() - 285,
			height: $(window).height() - 158 - 35,
			nowrap: false,
			pagination: true,
			pageSize: @ConstValues.DefaultGridRows,
			striped: true,
			toolbar: "#toolBar",
			pageSize: 100,
			pageList: [100, 200, 300, 400, 500],
			columns: [[
				{ field: "invoiceTitle", title: "@Resources.InvoiceTitle", align: "center", sortable: true, width: 300 },
				{ field: "taxNum", title: "@Resources.TaxNum", align: "center", sortable: true, width: 200 },
				{ field: "invoiceAmount", title: "@Resources.InvoiceAmount", align: "center", sortable: true, width: 100 },
				{ field: "feeCount", title: "@Resources.Count", align: "center", sortable: true, width: 100 }
			]],
			onBeforeLoad: function(param) {
				param.random = Math.random();
			}
		});

		$("#dataGrid5").datagrid({
			url: "@Url.Action(nameof(ConferenceStatisticsController.GetNotInvoice),
					nameof(ConferenceStatisticsController).GetControllerName(), new { ConferenceId = Model.ConferenceId })",
			method: "get",
			fitColumns: true,
			width: $(window).width() - 285,
			height: $(window).height() - 158 - 35,
			nowrap: false,
			pagination: true,
			pageSize: @ConstValues.DefaultGridRows,
			striped: true,
			toolbar: "#toolBar",
			pageSize: 100,
			pageList: [100, 200, 300, 400, 500],
			columns: [[
				{ field: "invoiceTitle", title: "@Resources.InvoiceTitle", align: "center", sortable: true, width: 300 },
				{ field: "taxNum", title: "@Resources.TaxNum", align: "center", sortable: true, width: 200 },
				{ field: "invoiceAmount", title: "@Resources.InvoiceAmount", align: "center", sortable: true, width: 100 },
				{ field: "feeCount", title: "@Resources.Count", align: "center", sortable: true, width: 100 }
			]],
			onBeforeLoad: function(param) {
				param.random = Math.random();
			}
		});

		$(window).resize(function () {
			$("#tt").tabs({
				width: $(window).width() - 270,
			});
			$("#dataGrid1").datagrid("resize", {
				width: $(window).width() - 285,
				height: $(window).height() - 158
			});
			$("#dataGrid2").datagrid("resize", {
				width: $(window).width() - 285,
				height: $(window).height() - 158
			});
			$("#dataGrid3").datagrid("resize", {
				width: $(window).width() - 285,
				height: $(window).height() - 158
			});
			$("#dataGrid4").datagrid("resize", {
				width: $(window).width() - 285,
				height: $(window).height() - 158
			});
			$("#dataGrid5").datagrid("resize", {
				width: $(window).width() - 285,
				height: $(window).height() - 158
			});
		});
	});

	function searchData(type) {
		if (type == 1) {
			$("#dataGrid1").datagrid("load", {
				TopicId: $("#ddlTopic").combobox("getValue"),
				JournalId: $("#ddlJournal").combobox("getValue")
			});
		}
		else if (type == 2) {
			var statisticsGroupType = $("#ddlStatisticsGroupType").combobox("getValue");
			$("#dataGrid2").datagrid("load", {
				StatisticsGroupType: statisticsGroupType
			});

			if (statisticsGroupType == "") {
				$("#dataGrid2").datagrid({
					columns: [[
						{ field: "country", title: "@Resources.Country", align: "center", sortable: true, width: 100 },
						{ field: "title", title: "@Resources.Title", align: "center", sortable: true, width: 100 },
						{ field: "job", title: "@Resources.Job", align: "center", sortable: true, width: 100 },
						{ field: "affiliation", title: "@Resources.Affiliation", align: "center", sortable: true, width: 100 },
						{ field: "paymentName", title: "@Resources.PaymentType", align: "center", sortable: true, width: 50 },
						{
							field: "hasPaid", title: "@Resources.PaidStatus", align: "center", sortable: true, width: 50,
							formatter: function (value, rec) {
								if (value == true) {
									return "@Resources.HasPaid";
								} else if (value == false) {
									return "@Resources.HasNotPaid";
								} else {
									return "";
								}
							}
						},
						{
							field: "hasArrived", title: "@Resources.HasArrived", align: "center", sortable: true, width: 50,
							formatter: function (value, rec) {
								if (value == true) {
									return "@Resources.Yes";
								} else if (value == false) {
									return "@Resources.No";
								} else {
									return "";
								}
							}
						},
						{ field: "count", title: "@Resources.Count", align: "center",  sortable: true, width: 100 }
					]],
					onBeforeLoad: function(param) {
						param.random = Math.random();
					},
				});
			} else if (statisticsGroupType == "@ConstValues.StatisticsGroupType.Country") {
				$("#dataGrid2").datagrid({
					columns: [[
						{ field: "country", title: "@Resources.Country", align: "center", sortable: true, width: 100 },
						{ field: "count", title: "@Resources.Count", align: "center",  sortable: true, width: 100 }
					]],
					onBeforeLoad: function(param) {
						param.random = Math.random();
					},
				});
			} else if (statisticsGroupType == "@ConstValues.StatisticsGroupType.Title") {
				$("#dataGrid2").datagrid({
					columns: [[
						{ field: "title", title: "@Resources.Title", align: "center", sortable: true, width: 100 },
						{ field: "count", title: "@Resources.Count", align: "center",  sortable: true, width: 100 }
					]],
					onBeforeLoad: function(param) {
						param.random = Math.random();
					},
				});
			} else if (statisticsGroupType == "@ConstValues.StatisticsGroupType.Job") {
				$("#dataGrid2").datagrid({
					columns: [[
						{ field: "job", title: "@Resources.Job", align: "center", sortable: true, width: 100 },
						{ field: "count", title: "@Resources.Count", align: "center",  sortable: true, width: 100 }
					]],
					onBeforeLoad: function(param) {
						param.random = Math.random();
					},
				});
			} else if (statisticsGroupType == "@ConstValues.StatisticsGroupType.Affiliation") {
				$("#dataGrid2").datagrid({
					columns: [[
						{ field: "affiliation", title: "@Resources.Affiliation", align: "center", sortable: true, width: 100 },
						{ field: "count", title: "@Resources.Count", align: "center",  sortable: true, width: 100 }
					]],
					onBeforeLoad: function(param) {
						param.random = Math.random();
					},
				});
			} else if (statisticsGroupType == "@ConstValues.StatisticsGroupType.PayType") {
				$("#dataGrid2").datagrid({
					columns: [[
						{ field: "paymentName", title: "@Resources.PaymentType", align: "center", sortable: true, width: 100 },
						{ field: "count", title: "@Resources.Count", align: "center", sortable: true, width: 100 }
					]],
					onBeforeLoad: function(param) {
						param.random = Math.random();
					},
				});
			} else if (statisticsGroupType == "@ConstValues.StatisticsGroupType.PaidStatus") {
				$("#dataGrid2").datagrid({
					columns: [[
						{
							field: "hasPaid", title: "@Resources.PaidStatus", align: "center", sortable: true, width: 100,
							formatter: function (value, rec) {
								if (value == true) {
									return "@Resources.HasPaid";
								} else if (value == false) {
									return "@Resources.HasNotPaid";
								} else {
									return "";
								}
							}
						},
						{ field: "count", title: "@Resources.Count", align: "center", sortable: true, width: 100 }
					]],
					onBeforeLoad: function(param) {
						param.random = Math.random();
					},
				});
			} else if (statisticsGroupType == "@ConstValues.StatisticsGroupType.ArriveStatus") {
				$("#dataGrid2").datagrid({
					columns: [[
						{
							field: "hasArrived", title: "@Resources.HasArrived", align: "center", sortable: true, width: 100,
							formatter: function (value, rec) {
								if (value == true) {
									return "@Resources.Yes";
								} else if (value == false) {
									return "@Resources.No";
								} else {
									return "";
								}
							}
						},
						{ field: "count", title: "@Resources.Count", align: "center", sortable: true, width: 100 }
					]],
					onBeforeLoad: function(param) {
						param.random = Math.random();
					},
				});
			}
		} else if (type == 3) {
			$("#dataGrid3").datagrid("load", {
				HotelId: $("#ddlHotel").combobox("getValue")
			});
		} else if (type == 4) {
			$("#dataGrid4").datagrid("load", {
				InvoiceTitle: $("#txtInvoiceTitle").textbox("getValue"),
				TaxNum: $("#txtTaxNum").textbox("getValue"),
			});
		} else if (type == 5) {
			$("#dataGrid5").datagrid("load", {
				InvoiceTitle: $("#txtNotInvoiceTitle").textbox("getValue"),
				TaxNum: $("#txtNotTaxNum").textbox("getValue"),
			});
		}
	}

	function exportInvoiceData() {
		$("#hidInvoiceTitle").val($("#txtInvoiceTitle").textbox("getValue"));
		$("#hidTaxNum").val($("#txtTaxNum").textbox("getValue"));
		$("#hidConferenceId").val("@Model.ConferenceId");
		$("#hidHasInvoiced").val("true");
		$("#invoiceExport").submit();
	}

	function exportNotInvoiceData() {
		$("#hidInvoiceTitle").val($("#txtNotInvoiceTitle").textbox("getValue"));
		$("#hidTaxNum").val($("#txtNotTaxNum").textbox("getValue"));
		$("#hidConferenceId").val("@Model.ConferenceId");
		$("#hidHasInvoiced").val("false");
		$("#invoiceExport").submit();
	}
</script>
}